#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e7+10;
const int mod = 20101009;

int mu[N],s[N],n,m,pnum,prime[N];
bool v[N];

void init(){
	mu[1] = 1;
	for(int i = 2;i < N;i++){
		if(!v[i]){mu[i] = -1;prime[++pnum] = i;}
		for(int j = 1,x;j <= pnum && prime[j] * i < N;j++){
			v[x = prime[j] * i] = 1;
			if(i % prime[j] == 0){mu[x] = 0;break;}
			mu[x] = -mu[i];
		}
	}
	for(int i = 1;i < N;i++) s[i] = (s[i-1] + 1ll * mu[i] * i * i % mod + mod) % mod;
}

int S(int x){return 1ll * x * (x+1) / 2 % mod;}

int F(int n,int m){
	int res = 0;
	for(int l = 1,r;l <= n;l = r+1){
		r = min(n/(n/l),m/(m/l));
		(res += 1ll * S(n/l) * S(m/l) % mod * (s[r] - s[l-1]) % mod) %= mod;
	}return (res + mod) % mod;
}

int solve(int n,int m){
	if(n > m) swap(n,m);int ans = 0;
	for(int l = 1,r;l <= n;l = r+1){
		r = min(n/(n/l),m/(m/l));
		(ans += 1ll * (r - l + 1) * (r + l) / 2 % mod * F(n/l,m/l) % mod) %= mod;
	}return (ans + mod) % mod;
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	init(); n = in,m = in;
	printf("%d\n",solve(n,m));
	return 0;
}

